package baseTest;

public class MaxProfit {
    public static void main(String[] args) {
        int[] price = {7,1,5,3,6,4};
        System.out.println(process(price));
    }
    public static int process(int[] price){
        int min = price[0];
        int maxValue = 0;
        for (int i = 1; i < price.length; i++) {
            int cur = price[i] - min;
            if ( cur > 0){
                maxValue = maxValue > cur ? maxValue : cur;
            }else {
                min = price[i];
            }
        }
        return maxValue;
    }
}
